<extend name="Public/common" />
<tagLib name="Editor"/>
<block name="body">
<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>文章管理</h3>
      <ul class="tab-base">
        	<li><a href="{:U('index')}"><span>列表</span></a></li>
	        <li><a href="JavaScript:void(0);" class="current"><span>新增</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <form id="form1" method="post" enctype="multipart/form-data" name="form1">
    <table class="table tb-type2">
      <tbody>
        <tr class="noborder">
          <td colspan="2" class="required"><label class="validation" for="article_title">文章标题:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="article_title" id="article_title" class="txt"></td>
          <td class="vatop tips">文章标题</td>
        </tr>
        
        <tr>
          <td colspan="2" class="required"><label class="validation" for="article_desc">文章简介:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><textarea name="article_desc" rows="6" class="tarea" id="article_desc" style="width: 400px;height: 100px"></textarea></td>
          <td class="vatop tips"><span class="vatop rowform">文章的简介描述，可以把突出重点的文字放在此处，不支持富文本</span></td>
        </tr> 
        
        <tr>
          <td colspan="2" class="required"><label class="validation" for="article_content">文章详情:</label></td>
        </tr>
        <tr class="noborder">
          <td colspan="2" class="vatop rowform"><editor:editor id="article_content" name="article_content" upload="1" media="1" type="all"></editor:editor></td>
        </tr>
                
        <tr>
          <td colspan="2" class="required"><label for="thumb">缩略图:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><span class="type-file-show"><img class="show_image" src="__IMG__/preview.png">
            <div class="type-file-preview"><img src="__IMG__/preview.png"></div></span>
            <span class="type-file-box"><input type='text' name='textfield' id='textfield1' class='type-file-text' /><input type='button' name='button' id='button1' value='' class='type-file-button' />
            <input name="thumb" type="file" class="type-file-file" id="thumb" size="30" hidefocus="true" nc_type="change_thumb">
            </span></td>
          <td class="vatop tips"><span class="vatop rowform">知识列表用的缩略图 {$thumbConfig['width']}px * {$thumbConfig['height']}px 系统支持的图片格式为:gif,jpg,jpeg,png</span></td>
        </tr>

        <tr>
          <td colspan="2" class="required">关注文章:</td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform onoff">
            <label for="is_subscribe1" class="cb-enable " ><span>开启</span></label>
            <label for="is_subscribe0" class="cb-disable selected" ><span>关闭</span></label>
            <input id="is_subscribe1" name="is_subscribe" value="1" type="radio">
            <input id="is_subscribe0" name="is_subscribe" checked="checked" value="0" type="radio">
          </td>
          <td class="vatop tips"><span class="vatop rowform">只在关注后出现</span></td>
        </tr>

        <tr>
          <td colspan="2" class="required"><label for="click">链接地址:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="" name="article_url" id="article_url" class="txt"></td>
          <td class="vatop tips">如果填写此地址，则打开直接跳此地址，不用填写详情。</td>
        </tr>
        
        <tr>
          <td colspan="2" class="required"><label for="click">查看次数:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="0" name="click" id="click" class="txt"></td>
          <td class="vatop tips">查看原文的次数</td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="share">分享次数:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="0" name="share" id="share" class="txt"></td>
          <td class="vatop tips">分享的次数</td>
        </tr>   

      </tbody>
      <tfoot>
        <tr class="tfoot">
          <td colspan="15" ><a href="JavaScript:void(0);" class="btn" id="submit"><span>提交</span></a></td>
        </tr>
      </tfoot>
    </table>
  </form>
</div>
<script type="text/javascript">
$(document).ready(function(){
	$('#form1').validate({
        errorPlacement: function(error, element){
			error.appendTo(element.parent().parent().prev().find('td:first'));
        },
        rules : {
        	article_title : {
                required : true
            },
            article_desc : {
                required : true
            },
            article_content : {
                required : true
            },
            click : {
                number   : true
            },
            share : {
                number   : true
            }
        },
        messages : {
        	article_title : {
                required : "文章标题必须填写"
            },
            article_desc : {
                required : "文章简介必须填写"
            },
            article_content : {
                required : "文章内容必须填写"
            },
            click : {
                number   : "查看数量只能为数字"
            },
            share : {
                number   : "分享数量只能为数字"
            }
        }
    });

	$("#thumb").change(function() {
		$("#textfield1").val($(this).val());
	});
	$('input[class="type-file-file"]').change(function() {
		var filepatd = $(this).val();
		var extStart = filepatd.lastIndexOf(".");
		var ext = filepatd.substring(extStart, filepatd.lengtd).toUpperCase();
		if (ext != ".PNG" && ext != ".GIF" && ext != ".JPG" && ext != ".JPEG") {
			alert("图片限于png,gif,jpeg,jpg格式");
			$(this).attr('value', '');
			return false;
		}
	});
	$("#submit").click(function() {
		if ($("#form1").valid()) {
			$("#form1").submit();
		}
	});
});
</script>
</block>